
	$(document).ready(function()
		{
			$.mobile.ajaxEnabled=false;
		});
	
	$(document).ready(function()
			{
				$("#userId").click(function()
				{
					 $('#info_userId').html("");
				});
				$("#userId").blur(function()
				{
					 
					var userId =$('#userId').val();
					
					 $.ajax({
					    	url:"getUserByUserId.action",
					 		type:'get',
					 		dataType:'json',
					 		data:{userId:userId},
					 		error:function(data)
					 		{
					 			alert("系统出现错误，请联系管理员。");
					 			
					 		},
					 		success:function(data)
					 		{
					
						          var result=data.result;  
						          $("#info_userId").html("<font color='red'>"+result+"</font>");
						                 
						    }  
						 
						    });  
			});
	});
	
	$(document).ready(function() {
		$("#password").change(function(){
			$('#confirmPassword').val("");
			
		});
	});
	
	jQuery.validator.addMethod("isMobile", function(value, element) {
		var length = value.length;
		var mobile = /^(\+86)?(1[0-9]{10})$/;
		return this.optional(element) || (length == 11 && mobile.test(value));
	}, " 请正确填写您的手机号码 ");
	$(document).ready(function() {
		$("#user_detail_form").validate({
			rules : {
				userId : {
					required : true,
					rangelength:[3,15]
				},
			
			name : 
			{
				required : true
				
			},
			password :"required",
			
			confirmPassword : 
			{
				required : true,
				equalTo: "#password"
			},
			age :
			{
				required:true,
				digits: true, 
				range: [1,100] 
			},
			email : 
			{
				required : true,
				email : true
			},
			tel : 
			{
				required : true,
				isMobile:true
			}
		},
		messages : 
		{
			userId : 
			{
				required : "请输入用户帐号",
				rangelength:"用户账号必须在3-15个数字之间(最好是您的手机号码)",
				remote:"对不起，该用户账号已经被占用"
			},
			name : 
			{
				required : "请输入用户姓名"
			},
			password : 
			{
				required : "请输入确认密码"
			},
			confirmPassword : 
			{
				required : "请输入确认密码",
				equalTo : "两次输入的密码不一致，请重新输入！"
			},
			age : 
			{
				required : "请输入您的年龄",
				digits:"请正确填写您的年龄",
				range:"您的年龄有问题吧,得在1-100岁之间哦" 
			},
			
			tel : 
			{
				required : "请输入电话",
				isMobile: " 请正确填写您的手机号码"
			},
			email : 
			{
				required : "请输入邮箱地址",
				email : "输入的邮箱地址不正确"
			}
			
		}
	});
});




			//利用struts2֤调用Action
			
			/*$.ajax({
				url:'add.action',
				type:'post',
				dataType:'json',
				//data:'name='+name+'&password='+password+'&sex='+$('#sex').attr('value')+'&age='+$('#age').attr('value')+'&tel='+$('#tel').attr('value')+'&email='+$('#email').attr('value')+'&photo='+$('#photo').attr('value'),
				data:$("form").serialize(),
				error:function(){
					location.href="list.action";
				},
				success:function(data)
				{
					if(data.message=="SUCCESS")
					{
						
						location.href="list.action";
					}
				}
				
			});*/

	$(document).ready(function()
			{
		        $('#radio_command').change(function(){
		        	var command=$('#radio_command').val();
		        	if("radio_save"==command)
		        	{
		        		$("#show_photo").show(); 
						$("#upload_photo").hide(); 
						$("#dealPhoto").val("save");
		        	}else if("radio_modify"==(command))
		        	{
		        		$("#show_photo").hide(); 
						$("#upload_photo").show(); 
						$("#dealPhoto").val("modify");
						$("#show_photo").hide(); 
		        	}else
		        	{
						$("#upload_photo").hide(); 
						$("#dealPhoto").val("delete");
		        	}
		        	
		        });
				
			});


	
	$(document).ready(function()
		{
			$("#back").click(function(){
				location.href='../admin_index.action';
			});
		}
	);